package com.example.controller;

import com.example.entity.Admin;
import com.example.service.ICacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.Optional;

/**
 * @author linjy on 2023/1/9
 */
@Slf4j
@RestController
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private ICacheService iCacheService;


    @PostMapping("/save")
    public String save() {
        iCacheService.save(new Admin(1L,"linjy", LocalDateTime.now()));
        return "save success";
    }


    @GetMapping("/getById")
    public String getById() {
        iCacheService.getById(1L);
        return "getById success";
    }

}
